
*** This file produces Figs A7, A10, A11, and A12. 
*** All of these start from a dataset that includes cities that were always 
*** districted during our sample period.


cd "$datadir"

 use "city_level_analysis_data_w_always_D.dta", replace
 
 
 *** First, produce Fig A7 
 
 gen renter_share=share_renter_occ_housing
 gen winner_renter_share=winner_share_renter_occ_housing
 
 replace post=1 if always_D==1
 
 	  local controls Unemployment_rate_ HPIwith2000base 
	  
	  
	  eststo clear

foreach x in cand_white  cand_hisp occ_BARF highincocc workingclass share_renter_occ_housing ln_pc_inc_yr {
	eststo `x':	reghdfe `x' post   , a( placefips year) cluster(placefips)

	eststo `x'_w:	reghdfe winner_`x' post  , a( placefips year) cluster(placefips)
}

   coefplot ( cand_white, asequation(Race/Eth.: White) \  cand_hisp, asequation(Race/Eth.: Hisp.) \  occ_BARF, asequation(Bus./Fin. Occ.) \  highincocc, asequation(High Inc. Occ.) \  workingclass, asequation(Working Class Occ.)   \ share_renter_occ_housing, asequation(N'hood: % Renter) \  ln_pc_inc_yr, asequation(N'hood: ln(PC Inc.)) ) (    cand_white_w, asequation(Race/Eth.: White) \  cand_hisp_w, asequation(Race/Eth.: Hisp.)  \    occ_BARF_w, asequation(Bus./Fin. Occ.) \ highincocc_w, asequation(High Inc. Occ.) \  workingclass_w, asequation(Working Class Occ.)   \ share_renter_occ_housing_w, asequation(N'hood: % Renter) \   ln_pc_inc_yr_w, asequation(N'hood: ln(PC Inc.)))    , keep(post)  xline(0) swapnames levels(95 90) xtitle(DiD Estimates - Impact of Districts)   legend( lab(3 "All Cands.") lab(6 "Winners")) 
   
    graph export "$dist_output/appx_main_outcomes_with_always_dist.png", as(png) name("Graph") replace 

	
	
	
	* And now, Fig A10-A12
	
gen never_treat=first_D_year==. & always_D_new!=1
gen treated= first_D_year!=. 

gen treat_cat=0 if first_D_year!=.
replace treat_cat=1 if always_D==1
replace treat_cat=2 if never_treat==1
	
drop if placefips==.
	 
collapse (mean)  cand_white cand_hisp  occ_BARF share_renter_occ_housing winner_cand_white winner_cand_hisp  winner_occ_BARF winner_share_renter_occ_housing, by(year   treat_cat)


 label var cand_white "White Cand. Share"
 label var cand_hisp  "Hisp. Cand. Share"
 label var occ_BARF "Bus. Occ. Cand. Share"
 label var share_renter_occ_housing "Cand. N'hood Renter Share"

 
twoway (connected cand_white year , sort)(connected cand_hisp year, sort) (connected share_renter_occ_housing year, sort) (connected occ_BARF year, sort) if treat_cat==0


 graph export "$dist_output/outcomes_time_series_switch.pdf", as(pdf) name("Graph") replace 

 
twoway (connected cand_white year , sort)(connected cand_hisp year, sort) (connected share_renter_occ_housing year, sort) (connected occ_BARF year, sort) if treat_cat==1


 graph export "$dist_output/outcomes_time_series_always.pdf", as(pdf) name("Graph") replace 

 
 
twoway (connected cand_white year , sort)(connected cand_hisp year, sort) (connected share_renter_occ_housing year, sort) (connected occ_BARF year, sort) if treat_cat==2


 graph export "$dist_output/outcomes_time_series_never.pdf", as(pdf) name("Graph") replace 

 
 
 